/**
 * Created by lj on 2018/1/9.
 */
load("js/luaclient.js")

var cardIndex = 1                    //卡序号
var data                             //卡数据
var billDates = new ArrayList()      //抓取账单日期数据
var notBill                          //未出账单数据
var monthBill                        //月份账单数据
var month                            //月份
var cardNo                           //卡号
var cardList = new ArrayList()       //卡列表
var dataList = new ArrayList()       //卡数据集合
var notBill = new ArrayList()        //未出账单
var types = new LinkedHashMap()
var chrs = new HashMap()
var credit_limit_global
var cash_limit_global
var balance
var cashBalance
var getTotalMonthPattern = Pattern.compile("[\\d.]+/[\\d.]+")

//初始化操作
function init(){
    var cs = new Array('零', '一', '二', '三', '四', '五', '六', '七', '八', '九', '十' )
    for (var i = 0; i < 11; i++) {
        chrs.put(cs[i], i)
    }
    types.put("工资", "SALARY")
    types.put("奖金", "BONUS")
    types.put("利息", "ACCRUAL")
    types.put("存现", "DEPOSIT")
    types.put("转账", "TRANSFER")
    types.put("普通汇兑", "TRANSFER")
    types.put("借货", "LOANS")
    types.put("冲账", "REVERSE")
    types.put("退款", "REFUND")
    types.put("结息转入", "EARNINGS")
    types.put("收益", "EARNINGS")
    types.put("报销", "CLAIM")
    types.put("其它收入", "OTHERREVENUE")
    types.put("燃油补贴", "OTHERREVENUE")
    types.put("取现", "WITHDRAW")
    types.put("支取", "WITHDRAW")
    types.put("手续费", "HANDLINGFEE")
    types.put("转账", "TRANSFER")
    types.put("网银入账", "TRANSFER")
    types.put("网银转入", "TRANSFER")
    types.put("还贷", "REPAYMENT")
    types.put("理财", "FINANCE")
    types.put("活转定", "FINANCE")
    types.put("存款户现金存款", "FINANCE")
    types.put("翼支付", "CONSUMPTION")
    types.put("消费", "CONSUMPTION")
    types.put("消费", "CONSUMPTION")
    types.put("出金", "CONSUMPTION")
    types.put("快捷支付", "CONSUMPTION")
    types.put("房租", "RENT")
    types.put("公积金", "FUND")
    types.put("社保", "SOCIALSECURITY")
    types.put("通讯费", "COMMUNICATIONFEE")
    types.put("生活费", "LIVINGEXPENSE")
    types.put("其它费用", "OTHERFEE")
    types.put("其它支出", "OTHEREXPENSE")
}

var v4_comm_mobile_credit_java_funcs = {
    //打开网页
    openHomePage : function(){
        var loginUrl = "https://creditcardapp.bankcomm.com/idm/sso/login.html?service=https://creditcardapp.bankcomm.com/member/shiro-cas"
        var loginIframe = get(loginUrl)
        //screen_print()
        storeDataToFile(context, loginIframe, "loginIframe.html")
        context.put("loginIframe", loginIframe)
    },
    checkControlAvailable: function () {
        return true
    },
    checkTargetWebsiteAvailable: function(){
        var isCorrectFunc = function () {
            return true
        }
        var getErrorMsgFunc = function () {
            return ""
        }
        return assertTrueOrThrowException("", isCorrectFunc, getErrorMsgFunc)

    },
    //检查代理是否可用
    checkProxyAvailable: function () {
        logger.info("COMM task:{}，检查当前代理是否可用{}", context.get(LUA_TASK_KEY), context.get(LUA_TASK_PROXY))
        var loginIframe = context.get("loginIframe")

        var checkProxyRight = function (loginIframe) {
            return !(loginIframe.contains("代理服务器没有响应") || loginIframe.contains("无法显示此页"))
        }
        var getProxyErrorMsg = function (html) {
            return "代理ip异常"
        }
        return assertTrueOrThrowException(loginIframe, checkProxyRight, getProxyErrorMsg)
    },
    login:function () {
        //将登录方式、是否存在短信验证 保存到context中
        saveLoginData()
        //选择登陆方式
        selectLoginStyle()
        //输入用户名
        inputUserName()
        //解析密码软键盘
        var pwdResult = getPassWord()
        //输入密码
        inputPassword(pwdResult)
        //输入图片验证码
        inputImgComm()
        //点击登陆按钮
        clickLoginButton()
        //是否存在短信验证，存在则输入短信验证码
        inputSmsComm()
        //是否存在浮动广告页，存在则关闭
        closeFloatingLogo()
        //验证是否登陆成功
        verifyLogin()

    },
    needRefreshHomePageOrNot : function() {
        return equals(context.get("currentErrorCode"), BALO_99602_50)
    },
    needResetEnvironment:function(){
        return equals(context.get("currentErrorCode"),BALO_99602_40)
    },
    //抓取过程
    crawl: function () {
        crawl()
    },
    exitLogin: function () {
    }

}
//是否是卡号登陆
function saveLoginData(){
    var cardNoLogin = CARDNO.equals(LoginType.stringToLoginType(context.get(LUA_TASK_LOGIN_TYPE)))
    context.put("cardNoLogin",cardNoLogin)
    context.put("smsComm",false)
    context.put("loginId","")
    context.put("loginTabId","")
}
//选择登录方式
function selectLoginStyle(){
    var loginId = ""
    var loginTabId = ""
    var name = ""
    switch (LoginType.stringToLoginType(context.get(LUA_TASK_LOGIN_TYPE))) {
        case CARDNO : // 卡号
            loginId = "cardNo"
            loginTabId = "tabCardNo"
            name = "卡号登录"
            break
        case MOBILE: // 手机号
            loginId = "mobileOrEmail"
            loginTabId = "tabMobileEmail"
            name = "手机号登录"
            break
        default:
            throw new BankException(BankConstants.BALO_22102_10, "当前银行不支持的登录方式")
    }
    logger.info("COMM task:{} 选择登陆方式:{}",context.get(LUA_TASK_KEY),name)
    //将登录方式的文本框id放入js上下文
    context.put("loginId",loginId)
    click_by_id(loginTabId)
}
//输入用户名称
function inputUserName() {
    // 输入用户名
    var username = getLoginParams(context)[0]
    logger.info("COMM task:{} 开始输入用户名",context.get(LUA_TASK_KEY))
    var typeUsernameResult = luaFuncs.typeUsername(context.get("loginId"),username)
    var isUsernameCorrectFunc = function (typeUsernameResult) {
        return typeUsernameResult
    }
    var getUsernameErrorMsgFunc = function(typeUsernameResult) {
        return "用户名未正确输入"
    }
    assertTrueOrThrowException(typeUsernameResult, isUsernameCorrectFunc, getUsernameErrorMsgFunc)
}
//输入密码
function inputPassword(password){
    logger.info("COMM task:{} 开始输入密码",context.get(LUA_TASK_KEY))
    var pwdResult = luaFuncs.inputCreditPwd(context.get("cardNoLogin"), password)
    var isPwdCorrectFunc = function (pwdResult) {
        return pwdResult
    }
    var getPwdErrorMsgFunc = function(pwdResult) {
        return "密码因控件输入错误"
    }
    assertTrueOrThrowException(pwdResult, isPwdCorrectFunc, getPwdErrorMsgFunc)
    logger.info("COMM task:{} 输入密码完成",context.get(LUA_TASK_KEY))
}
//输入图片验证码
function inputImgComm() {
    var dynamicCodeFlag=is_exist_by_id("dynamicCode")
    var  dynamicCode2Flag=is_exist_by_id("dynamicCode2")
    // 判断是否需要输入验证码
    if ( dynamicCodeFlag||dynamicCode2Flag) {
        logger.info("COMM task:{}，存在图片验证码", context.get(LUA_TASK_KEY))
        // 获取验证码
        var captchaResult = JSON.parse(luaFuncs.getCreditCaptcha(context.get("cardNoLogin")))
        var isCaptchaPathCorrectFunc = function(captchaResult) {
            return Boolean.valueOf(captchaResult.get("flag"))
        }
        var getCaptchaPathErrorMsgFunc = function(captchaResult) {
            return "图片验证码获取失败"
        }
        assertTrueOrThrowException(captchaResult, isCaptchaPathCorrectFunc, getCaptchaPathErrorMsgFunc)

        var imgPath = captchaResult.get("path")
        logger.info("COMM task:{}，图片验证码路径：{}", context.get(LUA_TASK_KEY),imgPath)

        //获取图片码值
        context.put(TASK_IMG_PATH, path)
        context.put(TASK_IMG_REGEX,"[0-9a-zA-Z]{4,5}")
        var code = waitImgCodeBySecondsByJs(context,60,true,3)
        logger.info("COMM task：{}，打码平台获取的图片验证码 :{} ",context.get(LUA_TASK_KEY), code)

        //输入图片码值
        var captchaResult = false
        if (context.get("cardNoLogin")) {
            captchaResult = JSON.parse(typeCaptcha("dynamicCode2", code.toLowerCase()))
        } else {
            captchaResult = JSON.parse(typeCaptcha("dynamicCode", code.toLowerCase()))
        }
        var captchaCorrectFunc = function (captchaResult) {
            return captchaResult
        }
        var captchaErrorMsgFunc = function(captchaResult) {
            return "图片验证码输入错误"
        }
        assertTrueOrThrowException(captchaResult, captchaCorrectFunc, captchaErrorMsgFunc)
        logger.info("COMM task:{}，输入图片验证码结束 ", context.get(LUA_TASK_KEY))

    }else{
        logger.info("COMM task:{}，不存在图片验证码环节 ", context.get(LUA_TASK_KEY))
    }
}
//点击登录按钮
function clickLoginButton(){
    var loginId = context.get("cardNoLogin") ? "cardLogin" : "loginBtn"
    var clickLoginResult = JSON.parse(luaFuncs.clickLoginButton(loginId))

    var clickLoginCorrectFunc = function (clickLoginResult) {
        return Boolean.valueOf(clickLoginResult.flag)
    }
    var clickLoginErrorMsgFunc = function(clickLoginResult) {
        return dealRtnMessage(clickLoginResult.errorMsg)
    }
    assertTrueOrThrowException(clickLoginResult, clickLoginCorrectFunc, clickLoginErrorMsgFunc)
}
//输入短信验证码
function inputSmsComm() {
    var smsExists = is_exist_by_id("moibleMessages")
    context.put("smsComm",smsExists)
    logger.info("COMM task：{}，是否需要短信验证码：{}",context.get(LUA_TASK_KEY),smsExists)
    var smsResult ={}
    if (smsExists) {
        click_by_id("send_Button")
        var verifyMessage = waitSmsCodeBySeconds(context,180)
        logger.info("COMM task：{}，获取的短信验证码：{} " ,context.get(LUA_TASK_KEY), verifyMessage)
        var inputContextResult = luaFuncs.inputContextById("moibleMessages",verifyMessage)
        logger.info("COMM task:{}，输入短信验证码后返回的值：{}",context.get(LUA_TASK_KEY), inputContextResult)
        var inputContextCorrectFunc = function (inputContextResult) {
            return inputContextResult
        }
        var inputContextErrorMsgFunc = function(inputContextResult) {
            return "输入短信验证码错误"
        }
        assertTrueOrThrowException(inputContextResult, inputContextCorrectFunc, inputContextErrorMsgFunc)
        logger.info("COMM task：{}，开始发送已收到的短信验证码",context.get(LUA_TASK_KEY))
        //点击发送短信验证码
        var smsFlagContextResult =  JSON.parse(luaFuncs.clickSubmit());
        var smsFlagContextCorrectFunc = function (smsFlagContextResult) {
            return Boolean.valueOf(smsFlagContextResult.flag)
        }
        var smsFlagContextErrorMsgFunc = function(smsFlagContextResult) {
            return smsFlagContextResult.errorMsg
        }
        assertTrueOrThrowException(smsFlagContextResult, smsFlagContextCorrectFunc, smsFlagContextErrorMsgFunc)
    }
}
//关闭浮动广告页面
function closeFloatingLogo(){
    var floatingLogoResult = luaFuncs.closeFloatingLogo()
    var floatingLogoCorrectFunc = function (floatingLogoResult) {
        return floatingLogoResult
    }
    var floatingLogoErrorMsgFunc = function(floatingLogoResult) {
        return "关闭浮动广告页面出错"
    }
    assertTrueOrThrowException(floatingLogoResult, floatingLogoCorrectFunc, floatingLogoErrorMsgFunc)
}
//获取密码的ascii值
function getPassWord()  {
    var asciiResult =JSON.parse(luaFuncs.getKeyImgAscii(context.get("cardNoLogin")))
    var pwdResult = ""
    var asciiFlag = asciiResult.get("flag")
    var times = 1
    while(!Boolean.valueOf(asciiFlag)&&times<=5){
        logger.info("COMM task:{} 重试第{}次获取软键盘的ascii",context.get(LUA_TASK_KEY),times)
        asciiResult =JSON.parse(luaFuncs.getKeyImgAscii(context.get("cardNoLogin")))
        asciiFlag = asciiResult.get("flag")
        times=times+1
    }
    logger.info("COMM task:{} 获取软键盘ascii是否成功：{}",context.get(LUA_TASK_KEY),asciiFlag)
    if(Boolean.valueOf(asciiFlag)){
        var asciis = asciiResult.get("ascii")
        //通过软件盘获取密码的ascii码值
        try{
            pwdResult = getPwdAscii(asciis)
        }catch(e){
            throw new BankException(BankConstants.BALO_22006_20, "软键盘解析失败")
        }
    }else{
        throw new BankException(BankConstants.BALO_22006_20, "软键盘解析失败")
    }
    logger.info("COMM task:{} 获取密码的ascii码值：{}",context.get(LUA_TASK_KEY),pwdResult)
    return pwdResult
}
function getPwdAscii(asciis){
    var password = context.get(LUA_TASK_TOKEN)
    logger.info("COMM task:{} 开始获取密码的asci码值,{}",context.get(LUA_TASK_KEY),password)
    var pwd = new StringBuilder();
    for (var i = 0; i < password.length; i++) {
        var index;
        var c = password.charAt(i);
        var indexAdd;
        if (isUpperCase(c)) {
            c = c.toLowerCase();
            indexAdd = 26;
        } else if (isLowerCase(c) || isDigit(c)) {

            indexAdd = 0;
        } else {
            indexAdd = 21;
        }
        index = indexForAsciis(asciis, c.charCodeAt()); // 获取字符在软键盘上的下标 //这里将char转为int
        if (index == -1) { // -1 表示错误
            var count = 0;
            for each(var string in asciis) {
                if (StringUtils.isNotBlank(string) && string.equals("-1")) {
                    count++;
                    if (count > 10) {
                        break;
                    }
                }
            }
            if (count > 8) {
                throw new BankException(BankConstants.BALO_22001_10, "软键盘解码有误！")
            } else {
                throw new BankException(BankConstants.BALO_22001_10,"密码中包含非法字符 _" + c + "_")
            }
        } else {
            index += indexAdd;
        }
        if (i < password.length - 1) {
            pwd.append(index+",");
        } else {
            pwd.append(index);
        }
    }
    var ps = pwd.toString();
    if(ps.length>0){
        ps = ps.substring(0,ps.length-2);
    }
    logger.info("COMM task:{} 获取密码的asci码值结束",context.get(LUA_TASK_KEY))
    return ps;

}
//查找字符位置
function indexForAsciis(asciis,ascii) {
    try {
        for (var i = 0 ;i < asciis.length; i++) {
            if (Integer.valueOf(asciis[i]) == ascii) {
                return i
            }
        }
        return -1
    } catch ( e) {
        //statCaughtException(context, e)
        throw new BankException(BankConstants.BALO_22001_10, "软键盘解码有误！")
        //logger.error("交通银行taskKey = {},软键盘查找字符位置出错！错误信息 : " ,context.get(LUA_TASK_KEY),e.message)
        //return -1
    }
}
//登录成果与否校验
function verifyLogin(){
    logger.info("COMM  task : {}，开始验证是否登录成功",context.get(LUA_TASK_KEY))
    var isSMS = context.get("smsComm")
    var loginId = context.get("loginId")
    var verifyLoginResult =JSON.parse(luaFuncs.verifyLogin(isSMS,loginId))
    if(null==verifyLoginResult){//这种情况属于lua脚本没有返回数据
        throw new BankException(BankConstants.BALO_23001_10, "新出现的错误提示，我方尚未归类(登录前)")
    }
    logger.info("COMM  task :{}验证返回信息：{} ",context.get(LUA_TASK_KEY),verifyLoginResult.get("alert"))

    var verifyLoginCorrectFunc = function (verifyLoginResult) {
        return Boolean.valueOf(verifyLoginResult.get("flag"))
    }
    var verifyLoginErrorMsgFunc = function(verifyLoginResult) {
        return dealRtnMessage(verifyLoginResult.get("alert"))
    }
    assertTrueOrThrowException(verifyLoginResult, verifyLoginCorrectFunc, verifyLoginErrorMsgFunc)
}
//异常信息处理
function dealRtnMessage(msgInfo) {
    var info = msgInfo
    logger.info("COMM  task :{}获取到的msgIngo信息：{} ",context.get(LUA_TASK_KEY),msgInfo)
    if(StringUtils.isBlank(msgInfo)||msgInfo.contains("error")){
        info = "新出现的错误提示，我方尚未归类(登录前)"

    }else if (msgInfo.contains("查询密码重置")) {
        info = "登录出错，需要重置密码！"

    }else if(msgInfo.contains("输入短信验证码错误")){
        info = "输入短信验证码错误"

    }else if(msgInfo.contains("请登录交行官网重置查询密码")){
        info = "请登录交行官网重置查询密码"

    }else if(msgInfo.contains("登录失败，请重新登录")){
        info = "登录失败，请重新登录"

    }else if(msgInfo.contains("系统繁忙，请稍候再试(登录前)") ){
        info = "系统繁忙，请稍候再试(登录前)"

    } else if (msgInfo.contains("系统繁忙") || msgInfo.contains("认证失败")) {
        info = "认证失败"

    } else if (msgInfo.contains("系统维护中")) {
        info = "系统维护中，请稍候再试(登录前)"

    } else if (msgInfo.contains("附属卡")) {
        info = "登录出错，需要重置密码！"

    } else if (msgInfo.contains("激活")) {
        info = "登录出错，需要重置密码！"

    } else if (msgInfo.contains("限制") || (msgInfo.contains("累计已达") && msgInfo.contains("密码"))) {
        info = "登录出错，需要重置密码！"

    } else if (msgInfo.contains("用户不存在") || msgInfo.contains("卡号格式错误") || msgInfo.contains("登录名错误")) {
        info = "用户名或密码错误，请重新输入"

    } else if (msgInfo.contains("密码") && msgInfo.contains("锁定账户")) {
        info = "您输入的密码错误次数已超限。请在次日重试或通过“忘记密码”重置，也可在柜台重置。"

    } else if (msgInfo.contains("为了您的账户安全") || msgInfo.contains("重新设置")) {
        info = "为了您的账户安全，请重新设置密码"

    } else if (msgInfo.contains("密码次数")) {
        info = "您输入的密码错误次数已超限。请在次日重试或通过“忘记密码”重置，也可在柜台重置。"

    } else if (msgInfo.contains("手机号或者邮箱")) {
        info = "用户名或密码错误，请重新输入"

    } else if (msgInfo.contains("登录密码未设置") || msgInfo.contains("请通过忘记密码设置")) {
        info = "登录密码未设置，请通过忘记密码设置"

    } else if(msgInfo.contains("登录异常！")){
        info = "登录异常！"
    }else if (msgInfo.length > 100) {
        info = "登录异常！"

    }
    return info
}
//抓取数据过程
function crawl() {
    queryCardList()                //获取卡列表
    analysisCardList()             //解析卡列表
    appCardList()                  //验证卡类表获取解析是否成功
    crawlCreditApp()               //获取解析信用卡账单信息
    completeCreditInfo()           //对账户的信息进行补全
    context.put("all_data", dataList);
}
//获取卡列表
function queryCardList() {
    logger.info("COMM taskkey：{}，开始抓取卡列表信息",context.get(LUA_TASK_KEY))
    var url = "https://creditcardapp.bankcomm.com/sac/user/cardList.html?callback=https://creditcardapp.bankcomm.com/member/member/home/index.html";
    var content =  requestUrlByGet(url);
    //screen_print()
    storeDataToFile(context,content,"cardList.html");
    context.put("cardList_content",content);
}
//解析卡列表
function analysisCardList(){
    try {
        logger.info("COMM taskkey：{}，开始解析卡列表信息",context.get(LUA_TASK_KEY))
        var content = context.get("cardList_content");
        var doc = Jsoup.parse(content);
        var divs = doc.select("div.items div.item");
        logger.info("COMM taskkey：{}，解析卡列表获取的item的个数：{}",context.get(LUA_TASK_KEY),divs.size())
        for each(var div in divs) {
            var rdivs = div.select("div.i-c > div");
            if (rdivs.size() >= 3) {
                logger.info("COMM taskkey：{}，解析卡列表获取rdivs的内容：{}",context.get(LUA_TASK_KEY),rdivs.text())
                var imgs = rdivs.get(0).select("img");
                if (imgs.size() == 2 && imgs.get(1).attr("src").contains("2.png") && rdivs.text().contains("交通银行")){
                    var as = rdivs.get(2).select("a");
                    if (as.size() > 0) {
                        var text = as.attr("onclick");
                        var id = getSingle("creditBo\\(\'(\\S+)\'\\)", text);
                        if (id !== null) {
                            var cardNo = doc.select("#" + id + " input").val();
                            logger.info("COMM taskkey：{}，解析卡列表获取的卡号:{}",context.get(LUA_TASK_KEY),cardNo)
                            if (StringUtils.isNotBlank(cardNo)) {
                                cardList.add(cardNo);
                            }
                        }
                    }
                }
            }
        }
        logger.info("COMM taskkey：{}，解析卡列表长度：{}",context.get(LUA_TASK_KEY),cardList.size())
    } catch (e) {
        statCaughtException(context, e);
        logger.info("comm taskKey:{}，解析卡列表异常：{}", context.get(LUA_TASK_KEY),e);
    }
}
function getSingle( express,  content) {
    var matcher = Pattern.compile(express).matcher(content)
    if (matcher.find()) {
        return matcher.group(1)
    }
    return null
}
function appCardList(){
    var getCardListBeforeCrawl = function () {
        return cardList.size() != 0
    }
    var getEmptyCardErrorMsg = function () {
        return "未获取到卡片信息，请登录官网绑定卡片"
    }
    return assertTrueOrThrowException("", getCardListBeforeCrawl, getEmptyCardErrorMsg)
}
//买单吧的抓取
function crawlCreditApp() {
    for (var i = 0; i < cardList.size(); i++) {
        //卡序号（第几张卡）
        logger.info("COMM taskkey：{}，执行第{}张卡账单信息的抓取",context.get(LUA_TASK_KEY),Integer.parseInt(cardIndex))
        //存放卡号信息
        cardNo = cardList.get(i)
        if (cardNo == null || "".equals(cardNo)) {
            cardNo = luaFuncs.getMyCardNo()
            logger.info("COMM taskkey：{}，抓取账单时获取的卡号：{}",context.get(LUA_TASK_KEY),cardNo)
        }
        data = new CreditCardAllData()
        dataList.add(data)

        queryBasicInfo()               //抓取基本信息
        analysisBasicInfo()            //解析基本信息
        queryTotalBill()               //抓取总账单信息
        analysisTotalBill()            //解析总账单信息
        dealCreateMonthBills()         // 已出账单 --- 抓取月份账单,解析月份账单,保存月份账单
        dealCreditLimit()              //设置额度信息
        dealUnCreateMonthBills()       // 未出账单 --- 抓取月份账单,解析月份账单,保存月份账单
        dealNewBalanceBills()          //设置余额信息
        dealFullCardNum()              //设置卡号信息
        cardIndex++
    }
}
//卡信息
function queryBasicInfo(){
    logger.info("COMM taskkey：{}，开始抓取第{}张卡基本信息",context.get(LUA_TASK_KEY),Integer.parseInt(cardIndex))
    var essay_url    = "https://creditcardapp.bankcomm.com/member/member/service/billing/balanceQry.html?cardNo=" + cardNo        // 可用额度、取现
    var account_url  = "https://creditcardapp.bankcomm.com/member/member/service/billing/pointInfoQry.html?cardNo=" + cardNo      // 开户
    var limit_url    = "https://creditcardapp.bankcomm.com/member/member/limit/info.json"                                         // 信用卡额度
    var person_url   = "https://creditcardapp.bankcomm.com/sac/user/account/index/baseinfo.json"                                  // 个人信息

    var essay_html   = requestUrlByGet(essay_url)
    //screen_print()
    var account_html = requestUrlByGet(account_url)
    //screen_print()
    var html = essay_html+account_html;

    var param = new HashMap()
    param.put("cardNo", cardNo)
    var limit_json   = requestUrlByPost(limit_url, param)
    //screen_print()
    var person_json  = requestUrlByPost(person_url, new HashMap())
    //screen_print()
    var json = limit_json + person_json;

    storeDataToFile(context,html, Integer.parseInt(cardIndex) + "_card.html")
    storeDataToFile(context,json, Integer.parseInt(cardIndex) + "_card.txt")
    storeDataToFile(context,limit_json, Integer.parseInt(cardIndex) + "_limit.txt")
    storeDataToFile(context,person_json, Integer.parseInt(cardIndex) + "_person.txt")
    context.put("basic_html",html)
    context.put("limit_json",limit_json)
    context.put("person_json",person_json)
    context.put("basic_json",json)
}
function analysisBasicInfo() {
    logger.info("COMM taskkey：{}，开始解析第{}张卡基本信息",context.get(LUA_TASK_KEY),Integer.parseInt(cardIndex))
    var bank_name = "交通银行" // 银行名称
    data.setCardId(UUID.randomUUID().toString())
    data.setBankName(bank_name)
    data.setCardType("信用卡")// 银行卡类型
    if(cardNo.contains("[")){
        cardNo=cardNo.substring(0,cardNo.indexOf("["))
    }
    data.setFullCardNum(cardNo)
    data.setCardNum(cardNo.substring(cardNo.length - 4, cardNo.length)) // 卡号后四位
    var person_json = context.get("person_json")
    var jsonStrObj = JSON.parseObject(person_json)// 姓名
    var obj = jsonStrObj.getJSONObject("user")
    var name = obj.getString("userName")
    if (name == null) {
        name = luaFuncs.getUserName()
    }
    data.setNameOnCard(removeSpace(name))
    //基本信息的解析与填充 如可用信用额度 可用额度等信息
    var basic_html = context.get("basic_html")
    var doc = Jsoup.parse(basic_html)
    var lis = doc.select("body ul li")
    for each(var li in lis) {
        var text = li.text()
        logger.info("text:"+text);
        if (text.contains("可用信用额度")) {
            // 可用信用额度
            var vals = text.split(",")
            if (vals.length <= 1) {
                var haveAmount = removeIllegal(vals[0])
                if (haveAmount !== null) {
                    data.setBalance(new BigDecimal(haveAmount))
                    balance =  data.getBalance();
                }
                //如果是多张卡，有的卡的额度是美元，这种情况看看是否是多张卡，如果有多张卡，默认它们的额度是共享的
            }
        } else if (text.contains("可用取现额度")) {
            // 可用取现额度
            var vals = text.split(",")
            if (vals.length <= 1) {
                var newCashCr = removeIllegal(vals[0])
                if (newCashCr !== null) {
                    data.setCashBalance(new BigDecimal(newCashCr))
                    cashBalance =  data.getCashBalance();
                }
            }
        } else if (text.contains("信用卡开户行")) {
            // 开户银行
            var  vals = text.split(" : ")
            if (vals.length > 1) {
                data.setOpenBank(vals[1])
            }
        }
    }
    //此处获取的text文件中有error的情况
    var limit_json = context.get("limit_json")
    var jsonObj = JSON.parseObject(limit_json)// 信用额度
    var amount = removeIllegal(jsonObj.getString("crdLmt"))//去除字符串中非法字符
    if (amount !== null) {
        data.setCreditLimit(new BigDecimal(amount))
    }
}
//抓取主账单信息
function queryTotalBill(){
    try{
        logger.info("COMM taskkey：{}，开始抓取第{}张卡的主账单信息",context.get(LUA_TASK_KEY),Integer.parseInt(cardIndex))
        var bill_url = "https://creditcardapp.bankcomm.com/member/member/service/billing/detail.html?cardNo=" + cardNo
        var bill_content = requestUrlByGet(bill_url)
        //screen_print()
        storeDataToFile(context,bill_content, Integer.parseInt(cardIndex)+"_total_bills.html")//第几张卡的账单
        context.put("bill_content",bill_content)
    }catch(e){
        statCaughtException(context, e)
        logger.error("COMM taskkey：{}，抓取第{}张卡的主账单信息出错：{}", context.get(LUA_TASK_KEY),Integer.parseInt(cardIndex),e)
    }
}
function analysisTotalBill(){
    logger.info("COMM taskkey：{}，开始解析第{}张卡总账单",context.get(LUA_TASK_KEY),Integer.parseInt(cardIndex))
    var bill_content = context.get("bill_content")
    var doc = Jsoup.parse(bill_content)
    if (cardNo == null || "".equals(cardNo)) {
        cardNo = doc.select("#mycard").val()
    }
    var ops = doc.select("#bill_date option")
    logger.info("COMM taskkey：{}，第{}张卡能查询的所有月份的账单 :{}",context.get(LUA_TASK_KEY),Integer.parseInt(cardIndex),ops.text())
    if(!ops.text().contains("本期无账单")){
        billDates = new ArrayList()
        for each(var op in ops) {
            billDates.add(op.attr("value"))
        }
    }
}
//信用卡入口 -已出账单
function  dealCreateMonthBills() {
    if(billDates.size()>0){
        logger.info("COMM taskkey：{}，开始抓取第{}张卡的已出账单",context.get(LUA_TASK_KEY),Integer.parseInt(cardIndex))
        for(var i=0;i<billDates.size();i++){
            try{
                month = billDates.get(i)
                //抓取月份已出账单
                queryCreateMonthBill()
                //解析月份已出账单
                analysisCreateMonthBill()
            }catch(e){
                context.put("monthBill","抓取和解析第"+Integer.parseInt(cardIndex)+"张卡的"+month+"月份已出账单过程中发生异常")
                logger.error("COMM taskkey：{}，抓取和解析第{}张卡{}月份已出账单异常:{}",context.get(LUA_TASK_KEY),Integer.parseInt(cardIndex),e)
            }
        }
        logger.info("COMM taskkey：{}，取第{}张卡抓取已出账单完成",context.get(LUA_TASK_KEY),Integer.parseInt(cardIndex))
    }else{
        logger.info("COMM taskkey：{}，本期无账单，未抓取第{}张卡的已出账单",context.get(LUA_TASK_KEY),Integer.parseInt(cardIndex))
    }
}
function queryCreateMonthBill(){
    logger.info("COMM taskkey：{}，开始抓取第{}张卡的{}月份账单",context.get(LUA_TASK_KEY),Integer.parseInt(cardIndex),month)
    if (StringUtils.isBlank(month) || !month.matches("\\d{8}")) {
        logger.info("COMM taskkey：{}，抓取第{}张卡{}月份为空或不规则,此月份账单不进行抓取",context.get(LUA_TASK_KEY),Integer.parseInt(cardIndex),month)
        return false;
    }
    var durl = "https://creditcardapp.bankcomm.com/member/member/service/billing/finished.html?cardNo=" + cardNo + "&billDate=" + month
    var monthBill = requestUrlByGet(durl)
    storeDataToFile(context,monthBill, Integer.parseInt(cardIndex) +"_"+month+ "_monthBills.html")
    context.put("monthBill",monthBill)
}
function analysisCreateMonthBill(){
    var monthBill = context.get("monthBill")
    logger.info("COMM taskkey：{}，开始解析第{}张卡{}月份账单",context.get(LUA_TASK_KEY),Integer.parseInt(cardIndex),month)
    var billList = data.getBills()
    var hisBill = new BillAllData()
    billList.add(hisBill)
    var doc = Jsoup.parse(monthBill)
    var tab1 = doc.select("table.bill-list")
    var trs1 = tab1.select("tr") // 本期财务说明
    var tab2 = doc.select("div.m-box2:contains(本期账单应还款额)")
    var trs2 = tab2.select("li")
    // 本期账单应还款额 = 上期账单应还款额(A) - 还款/退货/费用返还(B) + 消费/取现/其他费用(C)
    // 账单详情 --还款、退货及费用返还明细
    var dl = doc.select("dl.m-list")
    var trs3 = dl.select("dd")
    var repayCount = 0
    if (dl.size() > 0 && dl.select("dt:contains(还款、退货及费用返还明细)").size() > 0) {
        repayCount = dl.get(0).select("dd").size() // 还款、对货。。。条数
    }
    var params = new ArrayList()
    params.add(trs1)
    params.add(trs2)
    params.add(trs3)
    //保存信息
    saveBillsInfos(params, repayCount, "span", hisBill)
}
function dealCreditLimit(){
    logger.info("COMM taskkey：{}，开始设置第{}张卡额度信息",context.get(LUA_TASK_KEY),Integer.parseInt(cardIndex))
    //额度额度设置
    var creditLimit = data.getCreditLimit()
    if(creditLimit == null ) {
        var billList = data.getBills()
        if(billList!=null && billList.size()>0){
            for(var i =0;i<billList.size();i++) {
                var billAllData = billList.get(i)
                logger.info("billAllData.getCreditLimit():",billAllData.getCreditLimit())
                if(billAllData.getCreditLimit()!=null) {
                    data.setCreditLimit(billAllData.getCreditLimit())
                    break
                }
            }
        }
    }
    logger.info("COMM taskkey：{}，开始设置第{}张卡现金额度信息",context.get(LUA_TASK_KEY),Integer.parseInt(cardIndex))
    // 现金额度设置
    if(billList!=null && billList.size()>0){
        for(var i =0;i<billList.size();i++) {
            var billAllData = billList.get(i)
            logger.info("billAllData.getCashLimit():"+billAllData.getCashLimit());
            if(billAllData.getCashLimit()!=null) {
                data.setCashLimit(billAllData.getCashLimit())
                break
            }
        }
    }
}
function dealNewBalanceBills(){
    logger.info("COMM taskkey：{}，开始设置第{}张卡余额信息",context.get(LUA_TASK_KEY),Integer.parseInt(cardIndex))
    var new_balance = notBill.getNewBalance()
    if(new_balance==null){
        var billList = data.getBills()
        if (billList!==null&&billList.size()>0) {
            var lastNewDoneBill = billList.get(0)
            logger.info("COMM taskkey：{}，lastNewDoneBill:{}",context.get(LUA_TASK_KEY),Integer.parseInt(cardIndex),lastNewDoneBill)
            if(null!=lastNewDoneBill.getNewBalance()){
                notBill.setNewBalance(lastNewDoneBill.getNewBalance())
            }
        }
    }
}
function dealFullCardNum(){
    logger.info("COMM taskkey：{}，开始设置第{}张卡卡号信息",context.get(LUA_TASK_KEY),Integer.parseInt(cardIndex))
    if (context.get("cardNoLogin") && context.get(LUA_TASK_CARDNO) !== null &&
        context.get(LUA_TASK_CARDNO).length > 0 &&
        cardNo.substring(cardNo.length - 4).equals((context.get(LUA_TASK_CARDNO)).substring((context.get(LUA_TASK_CARDNO)).length - 4))){
        data.setFullCardNum((context.get(LUA_TASK_CARDNO)))
    } else {
        data.setFullCardNum(removeSpace(data.getFullCardNum()))
    }
}
//对账户的信息进行补全
function completeCreditInfo(){
    logger.info("COMM taskKey:{}，开始对账户的信息进行补全",context.get(LUA_TASK_KEY))
    for(var i=0;i<dataList.size();i++){
        var card = dataList.get(i)
        if (card != null) {
            var card_type = card.getCardType()
            if (StringUtils.isNotBlank(card_type) && card_type.equals("信用卡")) {
                if(null==card.getBalance()){
                    if(balance!=null){
                        card.setBalance(balance);
                    }
                }
                if(null==card.getCashLimit()){
                    if(cash_limit_global!=null){
                        card.setCashLimit(cash_limit_global);
                    }
                }
                if(null==card.getCreditLimit()){
                    if(credit_limit_global!=null){
                        card.setCreditLimit(credit_limit_global);
                    }
                }
                if(null==card.getCashBalance()){
                    if(cashBalance!=null){
                        card.setCashBalance(cashBalance);
                    }
                }
                var bills = card.getBills()
                // 每月的账单额度如果是0,那就是没提取到,设为null
                if (bills != null) {
                    for each(var billAllData in bills) {
                        var cash_limit = billAllData.getCashLimit()
                        if (cash_limit !== null && cash_limit.doubleValue() == 0) {
                            billAllData.setCashLimit(null)
                        }
                        var credit_limit = billAllData.getCreditLimit()
                        if (credit_limit !== null && credit_limit.doubleValue() == 0) {
                            billAllData.setCreditLimit(null)
                        }
                    }
                    // 卡的额度如果是0,那就是没提取到,设为null
                    var cash_limit = card.getCashLimit()
                    if (cash_limit !== null && cash_limit.doubleValue() == 0) {
                        card.setCashLimit(null)
                    }
                }
            }
        }
    }
}
//请求url重试策略，目前重试3次
function requestUrlByGet(url){
    logger.info("COMM taskkey：{}，get方式初次请求url：{}",context.get(LUA_TASK_KEY),url)
    var content =  luaFuncs.jiaotong_ajax_get(url)
    var times = 1
    while((StringUtils.isBlank(content)||content.trim().equals("return is null")||content.contains("服务超时，请稍后再试"))&&times<=3){
        logger.info("COMM taskkey：{}，get请求返回的content:{}",context.get(LUA_TASK_KEY),content)
        logger.info("COMM taskkey：{}，重试第{}次get方式请求url:{}",context.get(LUA_TASK_KEY),times,url)
        Thread.sleep(3000)
        times++;
        content =  luaFuncs.jiaotong_ajax_get(url)
    }
    logger.info("COMM taskkey：{}，get请求最终返回的content:{}",context.get(LUA_TASK_KEY),content)
    return content;
}
//请求url重试策略，目前重试3次
function requestUrlByPost(url,map){
    logger.info("COMM taskkey：{}，post请求初次请求url：{}",context.get(LUA_TASK_KEY),url)
    var content =  luaFuncs.jiaotong_ajax_post(url,map)
    var times = 1
    while((StringUtils.isBlank(content) || content.trim().equals("return is null")||content.contains("服务超时，请稍后再试"))&&times<=3){
        logger.info("COMM taskkey：{}，post请求返回的content:{}",context.get(LUA_TASK_KEY),content)
        logger.info("COMM taskkey：{}，重试第{}次post方式请求url:",context.get(LUA_TASK_KEY),times,url)
        Thread.sleep(3000)
        times++;
        content =  luaFuncs.jiaotong_ajax_post(url,map)
    }
    logger.info("COMM taskkey：{}，get请求最终返回的content:{}",context.get(LUA_TASK_KEY),content)
    return content;
}
//未出账单
function dealUnCreateMonthBills() {
    try {
        //抓取未出账单
        queryUnCreateMonthBill()
        //解析未出账单
        parserUndoBills()
    } catch (e) {
        logger.info("COMM taskkey：{}，抓取和解析第{}张卡未入账单异常：{}",context.get(LUA_TASK_KEY),Integer.parseInt(cardIndex),e)
    }
}
function queryUnCreateMonthBill(){
    var unCreateBillContent = new Array();
    logger.info("COMM taskkey：{}，开始抓取第{}张卡未入账账单",context.get(LUA_TASK_KEY),Integer.parseInt(cardIndex))
    var html = context.get("bill_content")
    var doc = Jsoup.parse(html)
    unCreateBillContent[0]=doc
    if (cardNo == null || "".equals(cardNo)) {
        cardNo = doc.select("#mycard").val()
    }
    logger.info("COMM taskkey：{}，开始抓取第{}张卡未入账普通账单",context.get(LUA_TASK_KEY),Integer.parseInt(cardIndex))
    // 未入账，未出账单 (三种不同的账单  普通的、人名币、美元)
    var url1 = "https://creditcardapp.bankcomm.com/member/member/service/billing/unpost.html?cardNo=" + cardNo
    var content1 = requestUrlByGet(url1)
    storeDataToFile(context,content1, Integer.parseInt(cardIndex) + "_undo_ordinary_bills.html")
    unCreateBillContent[1]=content1
    // 已入账，未出账单
    // 人民币
    logger.info("COMM taskkey：{}，开始抓取第{}张卡未入账人民币账单",context.get(LUA_TASK_KEY),Integer.parseInt(cardIndex))
    var url2 = "https://creditcardapp.bankcomm.com/member/member/service/billing/posted.html?cardNo=" + cardNo + "&ccyCod=156"
    var content2 = requestUrlByGet(url2)
    storeDataToFile(context,content2, Integer.parseInt(cardIndex) + "_undo_rmb_bills.html")
    unCreateBillContent[2]=content2
    // 美元
    logger.info("COMM taskkey：{}，开始抓取第{}张卡未入账美元账单",context.get(LUA_TASK_KEY),Integer.parseInt(cardIndex))
    var url3 = "https://creditcardapp.bankcomm.com/member/member/service/billing/posted.html?cardNo=" + cardNo + "&ccyCod=840"
    var content3 = requestUrlByGet(url3)
    storeDataToFile(context,content3, Integer.parseInt(cardIndex) + "_undo_us_bills.html")
    unCreateBillContent[3]=content3
    context.put("unCreateBillContent",unCreateBillContent)
}
//解析未出账单
function parserUndoBills() {
    logger.info("COMM taskkey：{}，开始解析第{}张卡未出账单",context.get(LUA_TASK_KEY),Integer.parseInt(cardIndex))
    notBill = new BillAllData()
    var billList = data.getBills()
    billList.add(0, notBill)
    if (billList.size() > 1) {
        var upBill = billList.get(1)
        notBill.setLastBalance(upBill.getNewBalance())
        notBill.setUsdLastBalance(upBill.getUsdNewBalance())
    } else {
        notBill.setLastBalance(null)
        notBill.setUsdLastBalance(null)
    }
    notBill.setMinPayment(null)
    notBill.setInterest(null)
    notBill.setUsdInterest(null)
    var sps = new ArrayList()
    notBill.setShoppingSheets(sps)
    notBill.setBillType("UNDONE")
    notBill.setBillId(UUID.randomUUID().toString())
    notBill.setBankName("交通银行")
    notBill.setCreditLimit(data.getCreditLimit())
    notBill.setCashLimit(data.getCashLimit())
    var new_charges = null
    var usd_new_charges = null
    notBill.setNewBalance(null)
    notBill.setUsdNewBalance(null)
    notBill.setUsdMinPayment(null)
    notBill.setNewCharges(null)
    notBill.setUsdNewCharges(null)
    notBill.setUsdCashLimit(null)
    notBill.setUsdCreditLimit(null)
    var unCreateBillContent = context.get("unCreateBillContent")
    var    doc   =  unCreateBillContent[0]
    var content1 =  unCreateBillContent[1]
    var content2 =  unCreateBillContent[2]
    var content3 =  unCreateBillContent[3]
    var ops = doc.select("#bill_date option")
    var lastDate = null // 最新一期已出账单
    for(var i=0;i<ops.size();i++) {
        var op = ops.get(i)
        if (op.text().contains("本期")) {
            lastDate = op.attr("value")
            break
        }
    }
    if (StringUtils.isNotBlank(lastDate)) {
        var billMonth = getLastMonth(lastDate)
        notBill.setBillDate(yyyy_MM_dd_PARSER.parse(billMonth))
        var c = Calendar.getInstance()
        c.setTime(TimeUtil.getTime(billMonth, "yyyy-MM-dd"))
        c.add(Calendar.MONTH, 1)
        c.add(Calendar.DATE, -6)
        var newPaydue = TimeUtil.getTimeStr(c.getTime(), "yyyy-MM-dd")
        notBill.setPaymentDueDate(null)
        notBill.setBillMonth(getDateStr(billMonth, "yyyy-MM-dd", "yyyy-MM"))
    } else {
        logger.info("COMM taskkey：{}，获取第{}张卡账单日失败,使用本月",context.get(LUA_TASK_KEY),Integer.parseInt(cardIndex))
        notBill.setBillMonth(TimeUtil.getTimeStr(new Date(), "yyyy-MM"))
    }
    var boxs = doc.select("#contentWrapper .content-box")
    notBill.setLastPayment(null)
    notBill.setUsdLastPayment(null)
    var huankuan_rmb = null
    var huankuan_usd = null
    if (boxs.size() == 3) {
        if (boxs.get(1).select("dl > dd").size() > 0) {
            var dds1 = boxs.get(1).select("dl > dd").get(0)
            // 已还金额：
            var  posts = dds1.text().split(",")
            if (posts.length > 0) {
                for each(var string in posts) {
                    if (StringUtils.isNotBlank(string)) {
                        if (string.contains("￥")) {
                            var balance = removeIllegal(string)
                            if (balance !== null) {
                                var last_payment = new BigDecimal("-" + balance);
                                notBill.setLastPayment(last_payment)
                            }
                        }
                        if (string.contains("＄")) {
                            var us_balance = removeIllegal(string)
                            if (us_balance !== null) {
                                var usd_last_payment = new BigDecimal(us_balance)
                                notBill.setUsdLastPayment(usd_last_payment)
                            }
                        }
                    }
                }

            }

        }
        var dds = boxs.get(2).select("dl > dd")
        if (dds.size() == 2) {
            // 消费/取现/其他费用合计
            var  posts = dds.get(0).text().split(",")
            if (posts.length > 0) {
                for each(var string in posts) {
                    if (StringUtils.isNotBlank(string)) {
                        if (string.contains("￥")) {
                            var balance = removeIllegal(string)
                            if (balance !== null) {
                                new_charges = new BigDecimal(balance)
                                notBill.setNewCharges(new_charges)
                            }
                        }
                        if (string.contains("＄")) {
                            var us_balance = removeIllegal(string)
                            if (us_balance !== null) {
                                usd_new_charges = new BigDecimal(us_balance)
                                notBill.setUsdNewCharges(new_charges)
                            }
                        }
                    }
                }

            }
            // 还款/退货/费用返还合计：
            var  posts = dds.get(1).text().split(",")
            if (posts.length > 0) {
                for each(var string in posts) {
                    if (StringUtils.isNotBlank(string)) {
                        if (string.contains("￥")) {
                            var balance = removeIllegal(string)
                            if (balance !== null) {
                                huankuan_rmb = balance
                            }
                        }
                        if (string.contains("＄")) {
                            var us_balance = removeIllegal(string)
                            if (us_balance !== null) {
                                huankuan_usd = us_balance
                            }
                        }
                    }
                }

            }

        }
    }
    var e1 = doc.select("#bill_content1 > dl > dd")
    for each(var element in e1) {
        var shangqizhangdan = element.text()
        shangqizhangdan = removeIllegal(shangqizhangdan)
        if (shangqizhangdan !== null && element.text().contains("-")) {
            shangqizhangdan = "-" + shangqizhangdan
        }
        if (element.text().contains("￥")) {
            if (huankuan_rmb !== null && new_charges !== null) {
                // 上期账单+本期账单-上期已还
                var d = new BigDecimal(shangqizhangdan).add(new_charges).subtract(new BigDecimal(huankuan_rmb))
                notBill.setNewBalance(d)
            }
        }
        if (element.text().contains("＄")) {
            if (huankuan_usd !== null && usd_new_charges !== null) {
                // 上期账单+本期账单-上期已还
                var d = new BigDecimal(shangqizhangdan).add(usd_new_charges).subtract(new BigDecimal(huankuan_usd))
                notBill.setUsdNewBalance(d)
            }
        }
    }
    saveCreditNotBills(content1)
    saveCreditNotBills(content2)
    saveCreditNotBills(content3)
}
//保存未出账单
function saveCreditNotBills( content) {
    var sps = notBill.getShoppingSheets()
    var order_index = sps.size()
    var doc = Jsoup.parse(content)
    var trs = doc.select(".bill-list table > tbody > tr")
    for each(var tr in trs) {
        var tds = tr.select("td")
        var desc = ""
        if (tds.size() == 2) {
            var ex = new Expense()
            ex.setId(UUID.randomUUID().toString())
            ex.setOrderIndex(++order_index)
            ex.setBalance(null)
            var ps = tds.get(0).select("p")
            var ps1 = tds.get(1).select("p")
            if (ps.size() > 1) {
                // 交易日期
                var tdate = ps.get(0).text()
                var transDate = DateUtil.parse(tdate, "yyyy-MM-dd");
                var postDate = DateUtil.parse(tdate, "yyyy-MM-dd");
                ex.setTransDate(transDate)
                ex.setPostDate(postDate)
                desc = ps.get(1).text()
            }
            if (ps1.size() > 1) {
                // 交易说明
                desc = desc + " " + ps1.get(1).text()
                ex.setDescription(desc)
                var category = classify(desc)
                ex.setCategory(category)
                // 交易币种/金额
                var type_amount = ps1.get(0).text()
                var currency_type = convertCurr(type_amount) // 币种
                ex.setCurrencyType(currency_type)
                var amount_money = removeIllegal(type_amount) // 金额
                if (amount_money !== null) {
                    var am = new BigDecimal(amount_money)
                    /**待调整
                     *由于分类规则改变，amountMoney正负判断逻辑需要调整
                     */
                    if ("PAYMENTS".equals(category)) {
                        am = am.multiply(new BigDecimal(-1))
                    }
                    ex.setAmountMoney(am)
                }
                // 卡号
                ex.setCardNum(cardNo.substring(cardNo.length - 4, cardNo.length))
            }
            sps.add(ex)
        }
    }
}
//已出账单解析保存，网银入口、信用卡入口通用
function saveBillsInfos( params,  repayCount,  ele,hisBill) {
    logger.info("COMM taskkey：{}，开始保存第{}张卡{}月账单",context.get(LUA_TASK_KEY),Integer.parseInt(cardIndex),month)
    var trs1 = params.get(0)
    var trs2 = params.get(1)
    var trs3 = params.get(2)
    hisBill.setBillType("DONE")
    hisBill.setBillId(UUID.randomUUID().toString())
    hisBill.setBankName("交通银行")
    hisBill.setBillMonth(getDateStr(month, "yyyyMMdd", "yyyy-MM"))
    hisBill.setInterest(null)
    hisBill.setUsdInterest(null)

    if (trs1 !== null && trs1.size() > 0) {
        var bill_date = getDateStr(month, "yyyyMMdd", "yyyy-MM-dd")// 账单日
        hisBill.setBillDate(yyyy_MM_dd_PARSER.parse(bill_date))
        var payment_due_date = trs1.get(0).select("td").get(0).text()// 到期还款日
        if (!payment_due_date.contains("---")) {
            hisBill.setPaymentDueDate(yyyy_MM_dd_PARSER.parse(getDateStr(payment_due_date, "yyyy/MM/dd", "yyyy-MM-dd")))
        } else {// 2017-08-17 发现有的人没有还款日,和产品临时决定使用这个算法
            var c = Calendar.getInstance()
            c.setTime(TimeUtil.getTime(bill_date, "yyyy-MM-dd"))
            c.add(Calendar.MONTH, 1)
            c.add(Calendar.DATE, -6)
            var newPaydue = TimeUtil.getTimeStr(c.getTime(), "yyyy-MM-dd")
            logger.info("COMM taskkey：{}，第{}张卡{}月没有找到最后还款日,只好自己计算{},{}",
                context.get(LUA_TASK_KEY),Integer.parseInt(cardIndex),month,payment_due_date,bill_date)
            hisBill.setPaymentDueDate(yyyy_MM_dd_PARSER.parse(newPaydue))
        }
        // 本期账单金额、美元
        var new_balance = removeIllegal(trs1.get(1).select("td").get(0).text())
        if (StringUtils.isNotBlank(new_balance)) {
            hisBill.setNewBalance(new BigDecimal(new_balance))
        } else {
            hisBill.setNewBalance(null)
        }
        var usd_new_balanceStr = trs1.get(1).select("td").get(1).text()
        var usd_new_balance = removeIllegal(usd_new_balanceStr)
        if (StringUtils.isNotBlank(usd_new_balance)) {
            hisBill.setUsdNewBalance(new BigDecimal(usd_new_balance))
        } else {
            hisBill.setUsdNewBalance(null)
        }
        // 最低还款额
        var min_payment = removeIllegal(trs1.get(2).select("td").get(0).text())
        if (StringUtils.isNotBlank(min_payment)) {
            hisBill.setMinPayment(new BigDecimal(min_payment))
        } else {
            hisBill.setMinPayment(null)
        }
        var usd_min_payment = removeIllegal(trs1.get(2).select("td").get(1).text())
        if (StringUtils.isNotBlank(usd_min_payment)) {
            hisBill.setUsdMinPayment(new BigDecimal(usd_min_payment))
        } else {
            hisBill.setUsdMinPayment(null)
        }
        // 信用卡额度、信用卡额度美元
        var credit_limit = removeIllegal(trs1.get(3).select("td").get(0).text())
        if (StringUtils.isNotBlank(credit_limit)) {
            hisBill.setCreditLimit(new BigDecimal(credit_limit))
            if (hisBill.getCreditLimit().doubleValue() > 0) {
                if(null==credit_limit_global){
                    credit_limit_global = hisBill.getCreditLimit()
                }
            }
        } else {
            hisBill.setCreditLimit(null)
        }
        var usd_credit_limit = removeIllegal(trs1.get(3).select("td").get(1).text())
        if (StringUtils.isNotBlank(usd_credit_limit)) {
            hisBill.setUsdCreditLimit(new BigDecimal(usd_credit_limit))
        } else {
            hisBill.setUsdCreditLimit(null)
        }
        // 信用卡额度、信用卡额度美元
        var cash_limit = removeIllegal(trs1.get(4).select("td").get(0).text())
        if (StringUtils.isNotBlank(cash_limit)) {
            hisBill.setCashLimit(new BigDecimal(cash_limit))
            if (hisBill.getCashLimit().doubleValue() > 0) {
                if(null==cash_limit_global){
                    cash_limit_global = hisBill.getCashLimit()
                }
            }
        } else {
            hisBill.setCashLimit(null)
        }
        var usd_cash_limit = removeIllegal(trs1.get(4).select("td").get(1).text())
        if (StringUtils.isNotBlank(usd_cash_limit)) {
            hisBill.setUsdCashLimit(new BigDecimal(usd_cash_limit))
        } else {
            hisBill.setUsdCashLimit(null)
        }
    }
    if (trs2 !== null && trs2.size() > 0) {
        // 上期账单金额、美元
        var last_balance = removeIllegal(trs2.get(1).select(ele).get(2).text())
        if (StringUtils.isNotBlank(last_balance)) {
            hisBill.setLastBalance(new BigDecimal(last_balance))
        } else {
            hisBill.setLastBalance(null)
        }
        var usd_last_balance = removeIllegal(trs2.get(2).select(ele).get(2).text())
        if (StringUtils.isNotBlank(usd_last_balance)) {
            hisBill.setUsdLastBalance(new BigDecimal(usd_last_balance))
        } else {
            hisBill.setUsdLastBalance(null)
        }
        // 上期还款金额、美元
        var last_payment = removeIllegal(trs2.get(1).select(ele).get(3).text())
        if (StringUtils.isNotBlank(last_payment)) {
            hisBill.setLastPayment(new BigDecimal(last_payment).multiply(new BigDecimal(-1)))
        } else {
            hisBill.setLastPayment(null)
        }
        var usd_last_payment = removeIllegal(trs2.get(2).select(ele).get(3).text())
        if (StringUtils.isNotBlank(usd_last_payment)) {
            hisBill.setUsdLastPayment(new BigDecimal(usd_last_payment))
        } else {
            hisBill.setUsdLastPayment(null)
        }
        // 本期新增款额、美元
        var new_charges = removeIllegal(trs2.get(1).select(ele).get(4).text())
        if (StringUtils.isNotBlank(new_charges)) {
            hisBill.setNewCharges(new BigDecimal(new_charges))
        } else {
            hisBill.setNewCharges(null)
        }
        var usd_new_charges = removeIllegal(trs2.get(2).select(ele).get(4).text())
        if (StringUtils.isNotBlank(usd_last_balance)) {
            hisBill.setUsdNewCharges(new BigDecimal(usd_new_charges))
        } else {
            hisBill.setUsdNewCharges(null)
        }
    }
    // 账单详情
    var exs = new ArrayList()
    hisBill.setShoppingSheets(exs)// 加入账单
    // 账单分期明细
    var ins = new ArrayList()
    hisBill.setInstallments(ins)  // 加入分期账单
    var ins_fee = new ArrayList() // 保存分期手续费
    var ins_hx = new ArrayList()
    var ins_hx_fee = new ArrayList() // 保存好享贷分期手续费
    var ins_tmp = new ArrayList() // 保存取消的分期，用于分析
    var order_index = 0 // 排序
    if (trs3 !== null) {
        var index = -1
        for each(var tr in trs3) {
            var tds = tr.select(ele)
            index++
            if (tds.size() == 5) { // 账单详情
                var ex = new Expense()
                ex.setBalance(null)
                ex.setId(UUID.randomUUID().toString())
                ex.setOrderIndex(++order_index)
                ex.setCardNum(cardNo.substring(cardNo.length - 4, cardNo.length))
                // 交易日期
                var trans_date = tds.get(0).text()
                ex.setTransDate(yyyy_MM_dd_HH_mm_ss_PARSER.parse(getDateStr(trans_date, "yyyy/MM/dd", "yyyy-MM-dd HH:mm:ss")))
                // 记账日期
                var post_date = tds.get(1).text()
                ex.setPostDate(yyyy_MM_dd_PARSER.parse(getDateStr(post_date, "yyyy/MM/dd", "yyyy-MM-dd")))
                // 交易说明
                var desc = tds.get(2).text()
                var category = judgeBillCategory(desc) // 消费类型
                ex.setCategory(category)
                ex.setDescription(desc)
                // 交易币种/金额
                var type_amount = tds.get(3).text()
                var currency_type = getCurrencyTypeStr(type_amount) // 币种
                ex.setCurrencyType(currency_type)
                var amount_money = removeIllegal(type_amount) // 金额
                var ls = getTotalMonth(desc) // 解析获取分期期数
                if (amount_money !== null) {
                    var am = new BigDecimal(amount_money)
                    if (index < repayCount) { // 还款、退货及费用返还明细
                        am = am.multiply(new BigDecimal(-1))
                    } else if (ls.size() == 0 && (desc.contains("退货") || desc.contains("转分期"))) { // 信贷分期交易明细
                        am = am.multiply(new BigDecimal(-1))
                    }
                    ex.setAmountMoney(am)
                }
                // 入账币种/金额
                var in_type_amount = tds.get(4).text()
                exs.add(ex)
                // 保存分期--
                if (ls.size() == 2 && desc.contains("分期") && ex.getAmountMoney().compareTo(new BigDecimal(0)) > 0) {
                    var inss = new Installment()
                    if (!desc.contains("余额转分期")) {
                        ins_hx.add(inss)
                    } else {
                        ins.add(inss)
                    }
                    inss.setTransDate(yyyy_MM_dd_HH_mm_ss_PARSER.parse(getDateStr(trans_date, "yyyy/MM/dd", "yyyy-MM-dd HH:mm:ss"))) // 交易日期
                    inss.setPostDate(yyyy_MM_dd_PARSER.parse(getDateStr(post_date, "yyyy/MM/dd", "yyyy-MM-dd")))// 记账日期
                    inss.setBillId(hisBill.getBillId())
                    inss.setShoppingsheetId(ex.getId())
                    inss.setInstallmentDesc(desc) // 分期描述
                    inss.setInstallmentType(installmentType(desc)) // 分期类型
                    // 交易币种/金额
                    inss.setCurrencyType(ex.getCurrencyType())
                    inss.setAmountMoney(ex.getAmountMoney())
                    // 分期总数
                    inss.setTotalMonth(ls.get(1))
                    // 当前分期数
                    inss.setCurrentMonth(ls.get(0))
                    if (desc.contains("退货取消")) {
                        ins_tmp.add(inss)
                    }
                } else if (desc.contains("好享贷分期手续费")) {
                    var insss = new Installment()
                    ins_hx_fee.add(insss)
                    insss.setHandingfeeDesc(desc) // 分期手续费描述
                    insss.setHandingFee(ex.getAmountMoney())// 交易币种/金额
                } else if (desc.contains("分期手续费")) {
                    var inssss = new Installment()
                    ins_fee.add(inssss)
                    inssss.setHandingfeeDesc(desc) // 分期手续费描述
                    inssss.setHandingFee(ex.getAmountMoney()) // 交易币种/金额
                }
            }
        }
    }
    var ins_remove = new ArrayList()
    for each(var installment in ins) {
        if (isNotInstallment(ins_tmp, installment.getInstallmentDesc())) {
            ins_remove.add(installment)
        }
    }
    for each(var installment in ins_hx) {
        if (isNotInstallment(ins_tmp, installment.getInstallmentDesc())) {
            ins_remove.add(installment)
        }
    }
    ins.removeAll(ins_remove)
    ins_hx.removeAll(ins_remove)
    logger.info("COMM taskkey：{}，ins.size:{} ins_fee.size:{} ins_hx.size:{} ins_hx_fee.size:{}",
        context.get(LUA_TASK_KEY), ins.size(), ins_fee.size(), ins_hx.size(), ins_hx_fee.size())
    if (ins.size() == ins_fee.size() && ins_hx.size() == ins_hx_fee.size()) {
        logger.info("COMM taskkey：{},第{}张卡分期格式化使用分支1",context.get(LUA_TASK_KEY),Integer.parseInt(cardIndex))
        formatInstallment(ins_hx, ins_hx_fee, ins_tmp)
        formatInstallment(ins, ins_fee, ins_tmp)
        ins.addAll(ins_hx)
    } else if (ins.size() + ins_hx.size() == ins_fee.size() + ins_hx_fee.size()) {
        logger.info("COMM taskkey：{},第{}张卡分期格式化使用分支2",context.get(LUA_TASK_KEY),Integer.parseInt(cardIndex))
        // 循环加入分期手续费， 账单中分期与分期手续费分别按顺序排列，之前按交易日期和记账日期对应错误， 20170712修改
        ins_fee.addAll(ins_hx_fee) // 好享贷的分期在最后
        ins.addAll(ins_hx)
        formatInstallment(ins, ins_fee, ins_tmp)
    } else {
        logger.info("COMM taskkey：{},第{}张卡分期格式化使用分支3",context.get(LUA_TASK_KEY),Integer.parseInt(cardIndex))
        // 循环加入分期手续费， 账单中分期与分期手续费分别按顺序排列，之前按交易日期和记账日期对应错误， 20170712修改
        ins_fee.addAll(ins_hx_fee) // 好享贷的分期在最后
        ins.addAll(ins_hx)
        for (var i = 0, j = 0; i < ins.size() ;i++) {
            var installment = ins.get(i)
            if (isNotInstallment(ins_tmp, installment.getInstallmentDesc())) {// 判断当前分期有无手续费
                installment.setHandingFee(new BigDecimal(0))// 分期手续费
                installment.setHandingfeeDesc("")// 分期手续费描述
            } else if (j < ins_fee.size()) {
                installment.setHandingFee(ins_fee.get(j).getHandingFee())// 分期手续费
                installment.setHandingfeeDesc(ins_fee.get(j).getHandingfeeDesc())// 分期手续费描述
                j++
            }
        }
    }

}

//格式化分期功能
function formatInstallment(ins, ins_fee,  ins_tmp) {

    if (ins.size() !== ins_fee.size()) {
        logger.error("ins 分期和手续费数量不相等")
    }

    for (var i = 0; i < ins.size() ;i++) {// 将分期按照顺序排列
        for (var j = 0; j < ins.size() - i - 1; j++) {
            var left = ins.get(j)
            var right = ins.get(j + 1)
            if (left.getAmountMoney().doubleValue() * left.getTotalMonth() > right.getAmountMoney().doubleValue() * right.getTotalMonth()) {
                ins.set(j, right)
                ins.set(j + 1, left)
            }
        }
    }
    for (var i = 0; i < ins_fee.size(); i++) {// 将分期手续费按照顺序排列
        for (var j = 0; j < ins_fee.size() - i - 1 ;j++) {
            var left = ins_fee.get(j)
            var right = ins_fee.get(j + 1)
            if (left.getHandingFee().doubleValue() > right.getHandingFee().doubleValue()) {
                ins_fee.set(j, right)
                ins_fee.set(j + 1, left)
            }
        }
    }
    for (var i = 0; i < Math.min(ins.size(), ins_fee.size()); i++) {
        var installment = ins.get(i)
        installment.setHandingFee(ins_fee.get(i).getHandingFee())// 分期手续费
        installment.setHandingfeeDesc(ins_fee.get(i).getHandingfeeDesc())// 分期手续费描述
    }
}

//判断当前分期是否有手续费 20170712
function isNotInstallment(ins_tmp, desc) {
    var iter = ins_tmp.iterator()
    while (iter.hasNext()) {
        var ins = iter.next()
        var tmp_desc = ins.getInstallmentDesc()
        if (tmp_desc.contains("退货取消")) {
            var ls = getTotalMonth(desc)
            var ls1 = getTotalMonth(tmp_desc)
            if (ls.size() == 2 && ls1.size() == 2 && ls.get(1) == ls1.get(1) && ls.get(0) == (ls1.get(0) + 1)) {
                var ins_desc = trimInnerSpaceStr(desc).split("\\s")
                if (ins_desc.length > 1 && tmp_desc.contains(ins_desc[1])) {
                    iter.remove()
                    return true
                }
            }
        }
    }
    return false
}

//去掉字符串前后的空间，中间的空格保留
function trimInnerSpaceStr(str) {
    str = str.trim()
    while (str.startsWith("\\s")) {
        str = str.substring(1, str.length).trim()
    }
    while (str.endsWith("\\s")) {
        str = str.substring(0, str.length - 1).trim()
    }
    return str
}

//获取下个月的今天
function getLastMonth( date) {
    if (date == null) {
        return ""
    }
    var year = Integer.valueOf(date.substring(0, 4))
    var month = Integer.valueOf(date.substring(4, 6))
    var day = Integer.valueOf(date.substring(6, 8))
    var cal = Calendar.getInstance()
    cal.set(year, month, day)
    cal.add(Calendar.MONTH, 0)// 取后一个月的同一天
    var d = cal.getTime()
    var formatter = new SimpleDateFormat("yyyy-MM-dd")
    return formatter.format(d)
}

//拆解分期中的月份，返回总期数和当前期数list
function getTotalMonth( str) {
    var s = null
    var m = getTotalMonthPattern.matcher(str)
    if (m.find()) {
        s = m.group()
    }
    var list = new ArrayList()
    if (s !== null) {
        var strs = s.split("/")
        for each(var ele in strs) {
            list.add(Integer.valueOf(ele))
        }
    }
    return list
}

//去掉字符串中除数字 小数点以外的其他字符
function removeIllegal(str) {
    if (str == null)
        return str
    str =  str.replace(/[^\d\.]/g,'')
    return "".equals(str) ? null : str
}

//根据描述判断账单的消费类型
function judgeBillCategory( description) {
    if (StringUtils.isBlank(description)) {
        return ""
    }
    if (description.contains("分期手续费")) {
        return "INSTALLMENT"
    }
    if (description.contains("分期消费扣款")) {
        return "INSTALLMENT"
    }

    // 判断是否是转分期一般转分期不包含
    // 分期:余额分期当月扣款 余额转分期十二期 <05/12>
    // 转分期:余额转分期十二期
    var iszhuanfenqi = description.contains("转分期") && !description.contains("<")
    if (description.contains("还款") || iszhuanfenqi || description.contains("转入") || description.contains("返还") || description.contains("代发款项")) {
        return "PAYMENTS"
    } else if (description.contains("取现") || description.contains("贷记卡转账")) {
        return "WITHDRAW"
    } else if (description.contains("消费")) {
        return "SHOPPING"
    } else if (description.contains("利息")) {
        return "INTEREST"
    } else if (description.contains("延滞金") || description.contains("滞纳金") || description.contains("违约金")) {
        return "OVERDUEPAYMENT"
    } else if (description.contains("超额费")) {
        return "OVERDUEFEE"
    } else if (description.contains("分期")) {
        return "INSTALLMENT"
    } else {
        return "OTHERFEE"
    }
}

function installmentType(description) {
    if (StringUtils.isBlank(description)) {
        return "CONSUME"
    }

    if (description.contains("分期付款") || description.contains("好享贷")) {
        return "CONSUME"
    } else if (description.contains("现金")) {
        return "CASH"
    } else if (description.contains("余额分期")) {
        return "BILL"
    } else {
        return "CONSUME"
    }
}

// 获取金额类型 人民币、 美元
function getCurrencyType(isDollar) {
    if (isDollar) {
        return "USD"
    } else {
        return "CNY"
    }
}

// 获取金额类型 人民币、 美元
function getCurrencyTypeStr( str) {
    if (str == null || str.equals("")) {
        return ""
    }
    if (str.contains("RMB") || str.contains("CNY") || str.contains("￥") || str.contains("人民币")) {
        return "CNY"
    } else {
        return "USD"
    }
}

/**
 * @param datestr
 *            要格式化的时间串
 * @param from_format
 *            初始格式(datestr的格式)
 * @param to_format
 *            改变后的格式(想要的格式)
 * @return
 */
function getDateStr( datestr,  from_format,  to_format) {
    if (datestr == null) {
        return null
    }
    var d = TimeUtil.getTime(datestr.trim(), from_format)
    if (d == null) {
        return ""
    }
    return TimeUtil.getTimeStr(d, to_format)
}

//去掉字符串中的空格
function removeSpace(str) {
    if (str == null)
        return str
    return str.replace(/\s/g,'')
}
//----------------抓取业务方法-----------------end


//-----------------lua的方法-----------------start

var luaFuncs = {
    getCookie: function () {
        var map = new HashMap()
        map.put("method", "getCookie")
        return sendAndReceive(map)
    },

    /**
     * 通过jiaotong_ajax_get方式get,注意跨域<br>
     * 在调用方法之前会进行域名校验,如果域名不相等,会返回跨域错误<br>
     * 因为有跳转问题,所以交通的单独拿出来了
     *
     * @param url
     * @return
     */
    jiaotong_ajax_get: function (url) {
        var map = new LinkedHashMap()
        map.put("method", "jiaotong_ajax_get")
        map.put("url", url)
        return sendAndReceive(map)
    },

    /**
     * 通过ajax方式post,注意跨域<br>
     * 在调用方法之前会进行域名校验,如果域名不相等,会返回跨域错误<br>
     * 因为有跳转问题,所以交通的单独拿出来了
     *
     * @param url
     * @param postdata
     * @return
     */
    jiaotong_ajax_post:function(url, postdata) {
        var map = new LinkedHashMap()
        var sb = new StringBuffer()
        for each(var key in postdata.keySet()){
            sb.append(key + "=" + postdata.get(key) + "&")
        }
        var data = ""
        if (sb.length > 0) {
            data = sb.substring(0, sb.length - 1)
        }
        map.put("method", "jiaotong_ajax_post")
        map.put("url", url)
        map.put("data", data)
        return sendAndReceive(map)
    },

    // 交通银行 判断是否需要图片验证码 并获取验证码路径
    getCaptcha: function () {
        var map = new HashMap()
        map.put("method", "getCaptcha")
        return sendAndReceive(map)
    },

    /**
     * 信用卡入口 获取验证码
     *
     * @param isCard
     *            --是否卡号输入
     * @return
     */
    getCreditCaptcha: function (isCard) {
        var map = new HashMap()
        map.put("method", "getCreditCaptcha")
        map.put("isCard", String.valueOf(isCard))
        return sendAndReceive(map)
    },

    /**
     * @param isCard
     *            --卡号登录？
     * @param pasword
     *            --密码
     * @return
     */
    inputCreditPwd: function (isCard, pasword) {
        var map = new HashMap()
        map.put("method", "inputCreditPwd")
        map.put("isCard", String.valueOf(isCard))
        map.put("password", pasword)
        return sendAndReceive(map)
    },

    /**
     * 获取页面中的卡号
     *
     * @return
     */
    getMyCardNo: function () {
        var map = new HashMap()
        map.put("method", "getMyCardNo")
        return sendAndReceive(map)
    },

    /**
     * 获取页面中的用户姓名
     *
     * @return
     */
    getUserName: function () {
        var map = new HashMap()
        map.put("method", "getUserName")
        return sendAndReceive(map)
    },

    /**
     * 获取键盘的ascii码值
     * @param isCard
     * @return
     */
    getKeyImgAscii: function (isCard) {
        var map = new HashMap()
        map.put("method", "getKeyImgAscii")
        map.put("isCard", String.valueOf(isCard))
        return sendAndReceive(map)
    },

    clickSubmit: function () {
        var map = new HashMap()
        map.put("method", "clickSubmit")
        return sendAndReceive(map)
    },

    screen_comm_print:function(){
        var map = new HashMap()
        map.put("method", "screen_comm_print")
        return sendAndReceive(map)
    },

    typeUsername:function(inputId,username){
        var map = new LinkedHashMap()
        map.put("inputId", inputId)
        map.put("username", username)
        map.put("method", "typeUsername")
        return sendAndReceive(map)
    },

    inputContextById:function(id,context){
        var map = new LinkedHashMap()
        map.put("id",id)
        map.put("context", context)
        map.put("method", "inputContextById")
        return sendAndReceive(map)
    },

    closeFloatingLogo:function(){
        var map = new LinkedHashMap()
        map.put("method", "closeFloatingLogo")
        return sendAndReceive(map)
    },

    typeCaptcha: function (id,code) {
        var map = new LinkedHashMap()
        map.put("method", "typeCaptcha")
        map.put("id", id)
        map.put("verifyCode", code)
        return sendAndReceive(map)
    },

    clickLoginButton: function (loginId) {
        var map = new LinkedHashMap()
        map.put("loginId", loginId)
        map.put("method", "clickLoginButton")
        return sendAndReceive(map)
    },

    verifyLogin:function(isSMS,loginId){
        var map = new LinkedHashMap()
        map.put("isSMS", isSMS)
        map.put("loginId",loginId)
        map.put("method", "verifyLogin")
        return sendAndReceive(map)
    }

}

